﻿package
{
	import com.mxprojects.constructors.SimpleTextField;
	import com.mxprojects.gui.Styles;
	import com.mxprojects.io.DeepLinking;
	import com.mxprojects.language.Word;
	
	import flash.display.MovieClip;
	import flash.events.TextEvent;
	import flash.text.TextFieldAutoSize;
	
	public class ContentTemplate extends MovieClip
	{
		private const BODY_WIDTH:int = 570;
		
		public function ContentTemplate(){ 
			//showSection("About"); CSS won't be loaded
		} 
		
		public function showSection(formattedArea:String):void {
			var headerText:String;
			var contentText:String;
			
			switch(formattedArea){
				case "About":
					headerText = "About MXP3";
					contentText = "The purpose of MXP3 is to bridge the gap in rich media sites requiring a message board / forum for their users to engage in without having to break out of the site. It allows the ability to use the Flash Platform in a whole new light to create a community experience like no other.";
					contentText += "\n\nYou can also use it as a traditional forum that you just link to from another page. It will run as a standalone forum just the same as if you integrated it into your Flash site.";
					contentText += "\n\nNow in it's 3rd major revision, the MX Projects forum (MXP for short) has become smaller and faster than it's previous versions. The forum was re-written from scratch to take advantage of the speed of AS3 as well as the robustness of the language. It uses PHP for the server-side scripting and mySQL for the database. It's been tested on both a LAMP and WAMP setup without a hitch.";
					contentText += "\n\nThat all being said, there is still lots of room for enhancements and requirements. <a href=\"event:wishlist\" class=\"link\">Head over to the wishlist/bugs forum</a> and voice your ideas or bugs <i>(there is bound to still be some lurking around)</i> and help keep the project healthy.";
					break;
				
				default:
					headerText = formattedArea;
					contentText = "Content not found";
					break;
			}
			
			var title:SimpleTextField = new SimpleTextField("<span class=\"header\">" + headerText + "</span>", 1, false, 0, true);
			
			//move the title
			title.x = Styles.extraCss.getStyle(".header").x;
			title.y = Styles.extraCss.getStyle(".header").y;
			addChild(title);
			
			//handle the body text
			var body:SimpleTextField = new SimpleTextField("", 2, true, BODY_WIDTH, true);
			body.x = title.x;
			body.y = title.y + title.height + 10;
			body.autoSize = TextFieldAutoSize.CENTER;
			body.htmlText = "<span class=\"body\">" + contentText + "</span>";
			body.addEventListener(TextEvent.LINK, handleLink, false, 0, true);
			addChild(body);
		}
				
		
		private function handleLink(event:TextEvent):void {
			//parse out the different options and go where we need to
			var forumID:int;
			switch(event.text){
				case "wishlist":
					forumID = 21;
					break;
				
				case "support":
					forumID = 4;
					break;
				
				case "addon":
					forumID = 6;
					break;
			}
			
			DeepLinking.setLink(Word.THREADS, DeepLinking.createLinkArray(forumID));
		}
	}
}